<template>
  <div class="mod-config">
    <div style="display: flex; justify-content:flex-end; width: 100%" >
      <el-button type="primary" @click="dataFormSubmit()" style="margin: 20px 50px;flex-end;">保存</el-button>
    </div>
    <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="150px">
      <el-form-item label="客服1" prop="customer1">
        <el-input v-model="dataForm.customer1" placeholder="客服1"></el-input>
      </el-form-item>
      <el-form-item label="客服2" prop="customer2">
        <el-input v-model="dataForm.customer2" placeholder="客服2"></el-input>
      </el-form-item>
      <el-form-item label="客服3" prop="customer3">
        <el-input v-model="dataForm.customer3" placeholder="客服3"></el-input>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {
          withdrawRate: '',
          virtualAmount: '',
          inviteRate: '',
          betMin: '',
          betMax: '',
          betOneBig: '',
          betOneSmall: '',
          betOneSingle: '',
          betOneDouble: '',
          betFiveBig: '',
          betFiveSmall: '',
          betFiveSingle: '',
          betFiveDouble: '',
          betTenBig: '',
          betTenSmall: '',
          betTenSingle: '',
          betTenDouble: '',
          ethAddress: '',
          trcAddress: '',
          customer1: '',
          customer2: '',
          customer3: ''
        },
        dataRule: {
        }
      }
    },
    created() {
      this.getInfo() 
    },
    methods: {
      getInfo () {
        this.$http({
          url: this.$http.adornUrl(`/biz/lotteryconfig/info`),
          method: 'get',
          params: this.$http.adornParams()
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataForm = data.config
          }
        })
      },
      // 表单提交
      dataFormSubmit () {
        this.$http({
          url: this.$http.adornUrl(`/biz/lotteryconfig/save`),
          method: 'post',
          data: this.$http.adornData({
            ...this.dataForm
          })
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.$message({
              message: '操作成功',
              type: 'success',
              duration: 1000,
            })
          } else {
            this.$message.error(data.msg)
          }
        })
      }
    }
  }
</script>
